
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>TypeScript 1.8 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="TypeScript 1.7.html" />
    
    
    <link rel="prev" href="TypeScript 2.0.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../handbook/tutorials/">
            
                <a href="../handbook/tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                <a href="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../handbook/tutorials/ASP.NET Core.html">
            
                <a href="../handbook/tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../handbook/tutorials/ASP.NET 4.html">
            
                <a href="../handbook/tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../handbook/tutorials/Gulp.html">
            
                <a href="../handbook/tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../handbook/tutorials/Knockout.html">
            
                <a href="../handbook/tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../handbook/tutorials/React & Webpack.html">
            
                <a href="../handbook/tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../handbook/tutorials/React.html">
            
                <a href="../handbook/tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../handbook/tutorials/Angular 2.html">
            
                <a href="../handbook/tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../handbook/tutorials/Migrating from JavaScript.html">
            
                <a href="../handbook/tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../handbook/">
            
                <a href="../handbook/">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../handbook/Basic Types.html">
            
                <a href="../handbook/Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../handbook/Variable Declarations.html">
            
                <a href="../handbook/Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../handbook/Interfaces.html">
            
                <a href="../handbook/Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../handbook/Classes.html">
            
                <a href="../handbook/Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../handbook/Functions.html">
            
                <a href="../handbook/Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../handbook/Generics.html">
            
                <a href="../handbook/Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../handbook/Enums.html">
            
                <a href="../handbook/Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../handbook/Type Inference.html">
            
                <a href="../handbook/Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../handbook/Type Compatibility.html">
            
                <a href="../handbook/Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../handbook/Advanced Types.html">
            
                <a href="../handbook/Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../handbook/Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../handbook/Symbols.html">
            
                <a href="../handbook/Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../handbook/Iterators and Generators.html">
            
                <a href="../handbook/Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="../handbook/Modules.html">
            
                <a href="../handbook/Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="../handbook/Namespaces.html">
            
                <a href="../handbook/Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="../handbook/Namespaces and Modules.html">
            
                <a href="../handbook/Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="../handbook/Module Resolution.html">
            
                <a href="../handbook/Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="../handbook/Declaration Merging.html">
            
                <a href="../handbook/Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="../handbook/Writing Definition Files.html">
            
                <a href="../handbook/Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="../handbook/JSX.html">
            
                <a href="../handbook/JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="../handbook/Decorators.html">
            
                <a href="../handbook/Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="../handbook/Mixins.html">
            
                <a href="../handbook/Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="../handbook/Triple-Slash Directives.html">
            
                <a href="../handbook/Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="../handbook/Type Checking JavaScript Files.html">
            
                <a href="../handbook/Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../handbook/declaration files/Introduction.html">
            
                <a href="../handbook/declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../handbook/declaration files/Library Structures.html">
            
                <a href="../handbook/declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../handbook/declaration files/Do's and Don'ts.html">
            
                <a href="../handbook/declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../handbook/declaration files/By Example.html">
            
                <a href="../handbook/declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../handbook/declaration files/Deep Dive.html">
            
                <a href="../handbook/declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../handbook/declaration files/Publishing.html">
            
                <a href="../handbook/declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../handbook/declaration files/Consumption.html">
            
                <a href="../handbook/declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../handbook/Project References.html">
            
                <a href="../handbook/Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../handbook/Typings for NPM Packages.html">
            
                <a href="../handbook/Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../handbook/Compiler Options.html">
            
                <a href="../handbook/Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../handbook/Configuring Watch.html">
            
                <a href="../handbook/Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../handbook/Compiler Options in MSBuild.html">
            
                <a href="../handbook/Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../handbook/Integrating with Build Tools.html">
            
                <a href="../handbook/Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../handbook/Nightly Builds.html">
            
                <a href="../handbook/Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="TypeScript 3.1.html">
            
                <a href="TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="TypeScript 3.0.html">
            
                <a href="TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="TypeScript 2.9.html">
            
                <a href="TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="TypeScript 2.8.html">
            
                <a href="TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="TypeScript 2.7.html">
            
                <a href="TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="TypeScript 2.6.html">
            
                <a href="TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="TypeScript 2.5.html">
            
                <a href="TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="TypeScript 2.4.html">
            
                <a href="TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="TypeScript 2.3.html">
            
                <a href="TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="TypeScript 2.2.html">
            
                <a href="TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="TypeScript 2.1.html">
            
                <a href="TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="TypeScript 2.0.html">
            
                <a href="TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.13" data-path="TypeScript 1.8.html">
            
                <a href="TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="TypeScript 1.7.html">
            
                <a href="TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="TypeScript 1.6.html">
            
                <a href="TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="TypeScript 1.5.html">
            
                <a href="TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.17" data-path="TypeScript 1.4.html">
            
                <a href="TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="TypeScript 1.3.html">
            
                <a href="TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="TypeScript 1.1.html">
            
                <a href="TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >TypeScript 1.8</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="typescript-18">TypeScript 1.8</h1>
<h2 id="&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7EA6;&#x675F;">&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7EA6;&#x675F;</h2>
<p>&#x5728; TypeScript 1.8 &#x4E2D;, &#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7684;&#x9650;&#x5236;&#x53EF;&#x4EE5;&#x5F15;&#x7528;&#x81EA;&#x540C;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x5217;&#x8868;&#x4E2D;&#x7684;&#x7C7B;&#x578B;&#x53C2;&#x6570;. &#x5728;&#x6B64;&#x4E4B;&#x524D;&#x8FD9;&#x79CD;&#x505A;&#x6CD5;&#x4F1A;&#x62A5;&#x9519;. &#x8FD9;&#x79CD;&#x7279;&#x6027;&#x901A;&#x5E38;&#x88AB;&#x53EB;&#x505A; <a href="https://en.wikipedia.org/wiki/Bounded_quantification#F-bounded_quantification" target="_blank">F-Bounded Polymorphism</a>.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">assign</span>&lt;<span class="hljs-title">T</span> <span class="hljs-title">extends</span> <span class="hljs-title">U</span>, <span class="hljs-title">U</span>&gt;(<span class="hljs-params">target: T, source: U</span>): <span class="hljs-title">T</span> </span>{
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> id <span class="hljs-keyword">in</span> source) {
        target[id] = source[id];
    }
    <span class="hljs-keyword">return</span> target;
}

<span class="hljs-keyword">let</span> x = { a: <span class="hljs-number">1</span>, b: <span class="hljs-number">2</span>, c: <span class="hljs-number">3</span>, d: <span class="hljs-number">4</span> };
assign(x, { b: <span class="hljs-number">10</span>, d: <span class="hljs-number">20</span> });
assign(x, { e: <span class="hljs-number">0</span> });  <span class="hljs-comment">// &#x9519;&#x8BEF;</span>
</code></pre>
<h2 id="&#x63A7;&#x5236;&#x6D41;&#x9519;&#x8BEF;&#x5206;&#x6790;">&#x63A7;&#x5236;&#x6D41;&#x9519;&#x8BEF;&#x5206;&#x6790;</h2>
<p>TypeScript 1.8 &#x4E2D;&#x5F15;&#x5165;&#x4E86;&#x63A7;&#x5236;&#x6D41;&#x5206;&#x6790;&#x6765;&#x6355;&#x83B7;&#x5F00;&#x53D1;&#x8005;&#x901A;&#x5E38;&#x4F1A;&#x9047;&#x5230;&#x7684;&#x4E00;&#x4E9B;&#x9519;&#x8BEF;.</p>
<p>&#x8BE6;&#x60C5;&#x89C1;&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x5185;&#x5BB9;, &#x53EF;&#x4EE5;&#x4E0A;&#x624B;&#x5C1D;&#x8BD5;:</p>
<p><img src="https://cloud.githubusercontent.com/assets/8052307/5210657/c5ae0f28-7585-11e4-97d8-86169ef2a160.gif" alt="cfa"></p>
<h3 id="&#x4E0D;&#x53EF;&#x53CA;&#x7684;&#x4EE3;&#x7801;">&#x4E0D;&#x53EF;&#x53CA;&#x7684;&#x4EE3;&#x7801;</h3>
<p>&#x4E00;&#x5B9A;&#x65E0;&#x6CD5;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x88AB;&#x6267;&#x884C;&#x7684;&#x8BED;&#x53E5;&#x73B0;&#x5728;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x4E0A;&#x4EE3;&#x7801;&#x4E0D;&#x53EF;&#x53CA;&#x9519;&#x8BEF;. &#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;, &#x5728;&#x65E0;&#x6761;&#x4EF6;&#x9650;&#x5236;&#x7684; <code>return</code>, <code>throw</code>, <code>break</code> &#x6216;&#x8005; <code>continue</code> &#x540E;&#x7684;&#x8BED;&#x53E5;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;&#x4E0D;&#x53EF;&#x53CA;&#x7684;. &#x4F7F;&#x7528; <code>--allowUnreachableCode</code> &#x6765;&#x7981;&#x7528;&#x4E0D;&#x53EF;&#x53CA;&#x4EE3;&#x7801;&#x7684;&#x68C0;&#x6D4B;&#x548C;&#x62A5;&#x9519;.</p>
<h4 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h4>
<p>&#x8FD9;&#x91CC;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x4E0D;&#x53EF;&#x53CA;&#x9519;&#x8BEF;&#x7684;&#x4F8B;&#x5B50;:</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params">x</span>) </span>{
    <span class="hljs-keyword">if</span> (x) {
       <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
    }
    <span class="hljs-keyword">else</span> {
       <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    x = <span class="hljs-number">0</span>; <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x68C0;&#x6D4B;&#x5230;&#x4E0D;&#x53EF;&#x53CA;&#x7684;&#x4EE3;&#x7801;.</span>
}
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x7279;&#x6027;&#x80FD;&#x6355;&#x83B7;&#x7684;&#x4E00;&#x4E2A;&#x66F4;&#x5E38;&#x89C1;&#x7684;&#x9519;&#x8BEF;&#x662F;&#x5728; <code>return</code> &#x8BED;&#x53E5;&#x540E;&#x6DFB;&#x52A0;&#x6362;&#x884C;:</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span>            <span class="hljs-comment">// &#x6362;&#x884C;&#x5BFC;&#x81F4;&#x81EA;&#x52A8;&#x63D2;&#x5165;&#x7684;&#x5206;&#x53F7;</span>
    {
        x: <span class="hljs-string">&quot;string&quot;</span>   <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x68C0;&#x6D4B;&#x5230;&#x4E0D;&#x53EF;&#x53CA;&#x7684;&#x4EE3;&#x7801;.</span>
    }
}
</code></pre>
<p>&#x56E0;&#x4E3A; JavaScript &#x4F1A;&#x81EA;&#x52A8;&#x5728;&#x884C;&#x672B;&#x7ED3;&#x675F; <code>return</code> &#x8BED;&#x53E5;, &#x4E0B;&#x9762;&#x7684;&#x5BF9;&#x8C61;&#x5B57;&#x9762;&#x91CF;&#x53D8;&#x6210;&#x4E86;&#x4E00;&#x4E2A;&#x4EE3;&#x7801;&#x5757;.</p>
<h3 id="&#x672A;&#x4F7F;&#x7528;&#x7684;&#x6807;&#x7B7E;">&#x672A;&#x4F7F;&#x7528;&#x7684;&#x6807;&#x7B7E;</h3>
<p>&#x672A;&#x4F7F;&#x7528;&#x7684;&#x6807;&#x7B7E;&#x4E5F;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;. &#x548C;&#x4E0D;&#x53EF;&#x53CA;&#x4EE3;&#x7801;&#x68C0;&#x67E5;&#x4E00;&#x6837;, &#x88AB;&#x4F7F;&#x7528;&#x7684;&#x6807;&#x7B7E;&#x68C0;&#x67E5;&#x4E5F;&#x662F;&#x9ED8;&#x8BA4;&#x5F00;&#x542F;&#x7684;. &#x4F7F;&#x7528; <code>--allowUnusedLabels</code> &#x6765;&#x7981;&#x7528;&#x672A;&#x4F7F;&#x7528;&#x6807;&#x7B7E;&#x7684;&#x62A5;&#x9519;.</p>
<h4 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h4>
<pre><code class="lang-ts">loop: <span class="hljs-keyword">while</span> (x &gt; <span class="hljs-number">0</span>) {  <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x672A;&#x4F7F;&#x7528;&#x7684;&#x6807;&#x7B7E;.</span>
    x++;
}
</code></pre>
<h3 id="&#x9690;&#x5F0F;&#x8FD4;&#x56DE;">&#x9690;&#x5F0F;&#x8FD4;&#x56DE;</h3>
<p>JS &#x4E2D;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x4EE3;&#x7801;&#x5206;&#x652F;&#x4F1A;&#x9690;&#x5F0F;&#x5730;&#x8FD4;&#x56DE; <code>undefined</code>. &#x73B0;&#x5728;&#x7F16;&#x8BD1;&#x5668;&#x53EF;&#x4EE5;&#x5C06;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x6807;&#x8BB0;&#x4E3A;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;. &#x5BF9;&#x4E8E;&#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x7684;&#x68C0;&#x67E5;&#x9ED8;&#x8BA4;&#x662F;&#x88AB;&#x7981;&#x7528;&#x7684;, &#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>--noImplicitReturns</code> &#x6765;&#x542F;&#x7528;.</p>
<h4 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h4>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params">x</span>) </span>{ <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x4E0D;&#x662F;&#x6240;&#x6709;&#x5206;&#x652F;&#x90FD;&#x8FD4;&#x56DE;&#x4E86;&#x503C;.</span>
    <span class="hljs-keyword">if</span> (x) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }

    <span class="hljs-comment">// &#x9690;&#x5F0F;&#x8FD4;&#x56DE;&#x4E86; `undefined`</span>
}
</code></pre>
<h3 id="case-&#x8BED;&#x53E5;&#x8D2F;&#x7A7F;">Case &#x8BED;&#x53E5;&#x8D2F;&#x7A7F;</h3>
<p>TypeScript &#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x5728; switch &#x8BED;&#x53E5;&#x4E2D;&#x51FA;&#x73B0;&#x8D2F;&#x7A7F;&#x7684;&#x51E0;&#x4E2A;&#x975E;&#x7A7A; case &#x65F6;&#x62A5;&#x9519;.
&#x8FD9;&#x4E2A;&#x68C0;&#x6D4B;&#x9ED8;&#x8BA4;&#x662F;&#x5173;&#x95ED;&#x7684;, &#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>--noFallthroughCasesInSwitch</code> &#x542F;&#x7528;.</p>
<h4 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h4>
<pre><code class="lang-ts"><span class="hljs-keyword">switch</span> (x % <span class="hljs-number">2</span>) {
    <span class="hljs-keyword">case</span> <span class="hljs-number">0</span>: <span class="hljs-comment">// &#x9519;&#x8BEF;: switch &#x4E2D;&#x51FA;&#x73B0;&#x4E86;&#x8D2F;&#x7A7F;&#x7684; case.</span>
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;even&quot;</span>);

    <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;odd&quot;</span>);
        <span class="hljs-keyword">break</span>;
}
</code></pre>
<p>&#x7136;&#x800C;, &#x5728;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;, &#x7531;&#x4E8E;&#x8D2F;&#x7A7F;&#x7684; case &#x662F;&#x7A7A;&#x7684;, &#x5E76;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">switch</span> (x % <span class="hljs-number">3</span>) {
    <span class="hljs-keyword">case</span> <span class="hljs-number">0</span>:
    <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Acceptable&quot;</span>);
        <span class="hljs-keyword">break</span>;

    <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;This is *two much*!&quot;</span>);
        <span class="hljs-keyword">break</span>;
}
</code></pre>
<h2 id="react-&#x65E0;&#x72B6;&#x6001;&#x7684;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;">React &#x65E0;&#x72B6;&#x6001;&#x7684;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;</h2>
<p>TypeScript &#x73B0;&#x5728;&#x652F;&#x6301;<a href="https://reactjs.org/docs/components-and-props.html#functional-and-class-components" target="_blank">&#x65E0;&#x72B6;&#x6001;&#x7684;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;</a>.
&#x5B83;&#x662F;&#x53EF;&#x4EE5;&#x7EC4;&#x5408;&#x5176;&#x4ED6;&#x7EC4;&#x4EF6;&#x7684;&#x8F7B;&#x91CF;&#x7EA7;&#x7EC4;&#x4EF6;.</p>
<pre><code class="lang-ts">// &#x4F7F;&#x7528;&#x53C2;&#x6570;&#x89E3;&#x6784;&#x548C;&#x9ED8;&#x8BA4;&#x503C;&#x8F7B;&#x677E;&#x5730;&#x5B9A;&#x4E49; &apos;props&apos; &#x7684;&#x7C7B;&#x578B;
const Greeter = ({name = &apos;world&apos;}) =&gt; &lt;div&gt;Hello, {name}!&lt;/div&gt;;

// &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x88AB;&#x68C0;&#x9A8C;
let example = &lt;Greeter name=&apos;TypeScript 1.8&apos; /&gt;;
</code></pre>
<p>&#x5982;&#x679C;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x8FD9;&#x4E00;&#x7279;&#x6027;&#x53CA;&#x7B80;&#x5316;&#x7684; props, &#x8BF7;&#x786E;&#x8BA4;&#x4F7F;&#x7528;&#x7684;&#x662F;<a href="https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/react" target="_blank">&#x6700;&#x65B0;&#x7684; react.d.ts</a>.</p>
<h2 id="&#x7B80;&#x5316;&#x7684;-react-props-&#x7C7B;&#x578B;&#x7BA1;&#x7406;">&#x7B80;&#x5316;&#x7684; React <code>props</code> &#x7C7B;&#x578B;&#x7BA1;&#x7406;</h2>
<p>&#x5728; TypeScript 1.8 &#x914D;&#x5408;&#x6700;&#x65B0;&#x7684; react.d.ts (&#x89C1;&#x4E0A;&#x65B9;) &#x5927;&#x5E45;&#x7B80;&#x5316;&#x4E86; <code>props</code> &#x7684;&#x7C7B;&#x578B;&#x58F0;&#x660E;.</p>
<p>&#x5177;&#x4F53;&#x7684;:</p>
<ul>
<li>&#x4F60;&#x4E0D;&#x518D;&#x9700;&#x8981;&#x663E;&#x5F0F;&#x7684;&#x58F0;&#x660E; <code>ref</code> &#x548C; <code>key</code> &#x6216;&#x8005; <code>extend React.Props</code></li>
<li><code>ref</code> &#x548C; <code>key</code> &#x5C5E;&#x6027;&#x4F1A;&#x5728;&#x6240;&#x6709;&#x7EC4;&#x4EF6;&#x4E0A;&#x62E5;&#x6709;&#x6B63;&#x786E;&#x7684;&#x7C7B;&#x578B;.</li>
<li><code>ref</code> &#x5C5E;&#x6027;&#x5728;&#x65E0;&#x72B6;&#x6001;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;&#x4E0A;&#x4F1A;&#x88AB;&#x6B63;&#x786E;&#x5730;&#x7981;&#x7528;.</li>
</ul>
<h2 id="&#x5728;&#x6A21;&#x5757;&#x4E2D;&#x6269;&#x5145;&#x5168;&#x5C40;&#x6216;&#x8005;&#x6A21;&#x5757;&#x4F5C;&#x7528;&#x57DF;">&#x5728;&#x6A21;&#x5757;&#x4E2D;&#x6269;&#x5145;&#x5168;&#x5C40;&#x6216;&#x8005;&#x6A21;&#x5757;&#x4F5C;&#x7528;&#x57DF;</h2>
<p>&#x7528;&#x6237;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x4E3A;&#x4EFB;&#x4F55;&#x6A21;&#x5757;&#x8FDB;&#x884C;&#x4ED6;&#x4EEC;&#x60F3;&#x8981;, &#x6216;&#x8005;&#x5176;&#x4ED6;&#x4EBA;&#x5DF2;&#x7ECF;&#x5BF9;&#x5176;&#x4F5C;&#x51FA;&#x7684;&#x6269;&#x5145;.
&#x6A21;&#x5757;&#x6269;&#x5145;&#x7684;&#x5F62;&#x5F0F;&#x548C;&#x8FC7;&#x53BB;&#x7684;&#x5305;&#x6A21;&#x5757;&#x4E00;&#x81F4; (&#x4F8B;&#x5982; <code>declare module &quot;foo&quot; { }</code> &#x8FD9;&#x6837;&#x7684;&#x8BED;&#x6CD5;), &#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5D4C;&#x5728;&#x4F60;&#x81EA;&#x5DF1;&#x7684;&#x6A21;&#x5757;&#x5185;, &#x6216;&#x8005;&#x5728;&#x53E6;&#x5916;&#x7684;&#x9876;&#x7EA7;&#x5916;&#x90E8;&#x5305;&#x6A21;&#x5757;&#x4E2D;.</p>
<p>&#x9664;&#x6B64;&#x4E4B;&#x5916;, TypeScript &#x8FD8;&#x4EE5; <code>declare global { }</code> &#x7684;&#x5F62;&#x5F0F;&#x63D0;&#x4F9B;&#x4E86;&#x5BF9;&#x4E8E;<em>&#x5168;&#x5C40;</em>&#x58F0;&#x660E;&#x7684;&#x6269;&#x5145;.
&#x8FD9;&#x80FD;&#x4F7F;&#x6A21;&#x5757;&#x5BF9;&#x50CF; <code>Array</code> &#x8FD9;&#x6837;&#x7684;&#x5168;&#x5C40;&#x7C7B;&#x578B;&#x5728;&#x5FC5;&#x8981;&#x7684;&#x65F6;&#x5019;&#x8FDB;&#x884C;&#x6269;&#x5145;.</p>
<p>&#x6A21;&#x5757;&#x6269;&#x5145;&#x7684;&#x540D;&#x79F0;&#x89E3;&#x6790;&#x89C4;&#x5219;&#x4E0E; <code>import</code> &#x548C; <code>export</code> &#x58F0;&#x660E;&#x4E2D;&#x7684;&#x4E00;&#x81F4;.
&#x6269;&#x5145;&#x7684;&#x6A21;&#x5757;&#x58F0;&#x660E;&#x5408;&#x5E76;&#x65B9;&#x5F0F;&#x4E0E;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x58F0;&#x660E;&#x662F;&#x76F8;&#x540C;&#x7684;.</p>
<p>&#x4E0D;&#x8BBA;&#x662F;&#x6A21;&#x5757;&#x6269;&#x5145;&#x8FD8;&#x662F;&#x5168;&#x5C40;&#x58F0;&#x660E;&#x6269;&#x5145;&#x90FD;&#x4E0D;&#x80FD;&#x5411;&#x9876;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#x6DFB;&#x52A0;&#x65B0;&#x7684;&#x9879;&#x76EE; - &#x5B83;&#x4EEC;&#x53EA;&#x80FD;&#x4E3A;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x7684;&#x58F0;&#x660E;&#x6DFB;&#x52A0; &quot;&#x8865;&#x4E01;&quot;.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<p>&#x8FD9;&#x91CC;&#x7684; <code>map.ts</code> &#x53EF;&#x4EE5;&#x58F0;&#x660E;&#x5B83;&#x4F1A;&#x5728;&#x5185;&#x90E8;&#x4FEE;&#x6539;&#x5728; <code>observable.ts</code> &#x4E2D;&#x58F0;&#x660E;&#x7684; <code>Observable</code> &#x7C7B;&#x578B;, &#x6DFB;&#x52A0; <code>map</code> &#x65B9;&#x6CD5;.</p>
<pre><code class="lang-ts"><span class="hljs-comment">// observable.ts</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> Observable&lt;T&gt; {
    <span class="hljs-comment">// ...</span>
}
</code></pre>
<pre><code class="lang-ts"><span class="hljs-comment">// map.ts</span>
<span class="hljs-keyword">import</span> { Observable } from <span class="hljs-string">&quot;./observable&quot;</span>;

<span class="hljs-comment">// &#x6269;&#x5145; &quot;./observable&quot;</span>
<span class="hljs-keyword">declare</span> <span class="hljs-keyword">module</span> &quot;./observable&quot; {

    <span class="hljs-comment">// &#x4F7F;&#x7528;&#x63A5;&#x53E3;&#x5408;&#x5E76;&#x6269;&#x5145; &apos;Observable&apos; &#x7C7B;&#x7684;&#x5B9A;&#x4E49;</span>
    <span class="hljs-keyword">interface</span> Observable&lt;T&gt; {
        map&lt;U&gt;(proj: (el: T) =&gt; U): Observable&lt;U&gt;;
    }

}

Observable.prototype.map = <span class="hljs-comment">/*...*/</span>;
</code></pre>
<pre><code class="lang-ts"><span class="hljs-comment">// consumer.ts</span>
<span class="hljs-keyword">import</span> { Observable } from <span class="hljs-string">&quot;./observable&quot;</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;./map&quot;</span>;

<span class="hljs-keyword">let</span> o: Observable&lt;<span class="hljs-built_in">number</span>&gt;;
o.map(x =&gt; x.toFixed());
</code></pre>
<p>&#x76F8;&#x4F3C;&#x7684;, &#x5728;&#x6A21;&#x5757;&#x4E2D;&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>declare global</code> &#x58F0;&#x660E;&#x88AB;&#x589E;&#x5F3A;:</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x786E;&#x4FDD;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x88AB;&#x5F53;&#x505A;&#x4E00;&#x4E2A;&#x6A21;&#x5757;.</span>
<span class="hljs-keyword">export</span> {};

<span class="hljs-keyword">declare</span> global {
    <span class="hljs-keyword">interface</span> Array&lt;T&gt; {
        mapToNumbers(): <span class="hljs-built_in">number</span>[];
    }
}

<span class="hljs-built_in">Array</span>.prototype.mapToNumbers = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">/* ... */</span> }
</code></pre>
<h2 id="&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x7C7B;&#x578B;">&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x7C7B;&#x578B;</h2>
<p>&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x5B57;&#x7B26;&#x4E32;&#x96C6;&#x5408;&#x4F5C;&#x4E3A;&#x67D0;&#x4E2A;&#x503C;&#x7684; API &#x5E76;&#x4E0D;&#x5C11;&#x89C1;.
&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;, &#x8003;&#x8651;&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x63A7;&#x5236;<a href="https://en.wikipedia.org/wiki/Inbetweening" target="_blank">&#x52A8;&#x753B;&#x7684;&#x6E10;&#x53D8;</a>&#x8BA9;&#x5143;&#x7D20;&#x5728;&#x5C4F;&#x5E55;&#x4E2D;&#x6ED1;&#x52A8;&#x7684; UI &#x5E93;:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">declare</span> <span class="hljs-keyword">class</span> UIElement {
    animate(options: AnimationOptions): <span class="hljs-built_in">void</span>;
}

<span class="hljs-keyword">interface</span> AnimationOptions {
    deltaX: <span class="hljs-built_in">number</span>;
    deltaY: <span class="hljs-built_in">number</span>;
    easing: <span class="hljs-built_in">string</span>; <span class="hljs-comment">// &#x53EF;&#x4EE5;&#x662F; &quot;ease-in&quot;, &quot;ease-out&quot;, &quot;ease-in-out&quot;</span>
}
</code></pre>
<p>&#x7136;&#x800C;, &#x8FD9;&#x5BB9;&#x6613;&#x4EA7;&#x751F;&#x9519;&#x8BEF; - &#x5F53;&#x7528;&#x6237;&#x9519;&#x8BEF;&#x4E0D;&#x5C0F;&#x5FC3;&#x9519;&#x8BEF;&#x62FC;&#x5199;&#x4E86;&#x4E00;&#x4E2A;&#x5408;&#x6CD5;&#x7684;&#x503C;&#x65F6;, &#x5E76;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x63D0;&#x793A;:</p>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6CA1;&#x6709;&#x62A5;&#x9519;</span>
<span class="hljs-keyword">new</span> UIElement().animate({ deltaX: <span class="hljs-number">100</span>, deltaY: <span class="hljs-number">100</span>, easing: <span class="hljs-string">&quot;ease-inout&quot;</span> });
</code></pre>
<p>&#x5728; TypeScript 1.8 &#x4E2D;, &#x6211;&#x4EEC;&#x65B0;&#x589E;&#x4E86;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x7C7B;&#x578B;. &#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x548C;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x7684;&#x5199;&#x6CD5;&#x4E00;&#x81F4;, &#x53EA;&#x662F;&#x5199;&#x5728;&#x7C7B;&#x578B;&#x7684;&#x4F4D;&#x7F6E;.</p>
<p>&#x7528;&#x6237;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;&#x4F1A;&#x6355;&#x83B7;&#x8FD9;&#x6837;&#x7684;&#x9519;&#x8BEF;.
&#x8FD9;&#x91CC;&#x662F;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E86;&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x7C7B;&#x578B;&#x7684;&#x65B0;&#x7684; <code>AnimationOptions</code>:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> AnimationOptions {
    deltaX: <span class="hljs-built_in">number</span>;
    deltaY: <span class="hljs-built_in">number</span>;
    easing: <span class="hljs-string">&quot;ease-in&quot;</span> | <span class="hljs-string">&quot;ease-out&quot;</span> | <span class="hljs-string">&quot;ease-in-out&quot;</span>;
}

<span class="hljs-comment">// &#x9519;&#x8BEF;: &#x7C7B;&#x578B; &apos;&quot;ease-inout&quot;&apos; &#x4E0D;&#x80FD;&#x590D;&#x5236;&#x7ED9;&#x7C7B;&#x578B; &apos;&quot;ease-in&quot; | &quot;ease-out&quot; | &quot;ease-in-out&quot;&apos;</span>
<span class="hljs-keyword">new</span> UIElement().animate({ deltaX: <span class="hljs-number">100</span>, deltaY: <span class="hljs-number">100</span>, easing: <span class="hljs-string">&quot;ease-inout&quot;</span> });
</code></pre>
<h2 id="&#x66F4;&#x597D;&#x7684;&#x8054;&#x5408;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;&#x63A5;&#x53E3;">&#x66F4;&#x597D;&#x7684;&#x8054;&#x5408;/&#x4EA4;&#x53C9;&#x7C7B;&#x578B;&#x63A5;&#x53E3;</h2>
<p>TypeScript 1.8 &#x4F18;&#x5316;&#x4E86;&#x6E90;&#x7C7B;&#x578B;&#x548C;&#x76EE;&#x6807;&#x7C7B;&#x578B;&#x90FD;&#x662F;&#x8054;&#x5408;&#x6216;&#x8005;&#x4EA4;&#x53C9;&#x7C7B;&#x578B;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x7684;&#x7C7B;&#x578B;&#x63A8;&#x5BFC;.
&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;, &#x5F53;&#x4ECE; <code>string | string[]</code> &#x63A8;&#x5BFC;&#x5230; <code>string | T</code> &#x65F6;, &#x6211;&#x4EEC;&#x5C06;&#x7C7B;&#x578B;&#x62C6;&#x89E3;&#x4E3A; <code>string[]</code> &#x548C; <code>T</code>, &#x8FD9;&#x6837;&#x5C31;&#x53EF;&#x4EE5;&#x5C06; <code>string[]</code> &#x63A8;&#x5BFC;&#x4E3A; <code>T</code>.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-keyword">type</span> Maybe&lt;T&gt; = T | <span class="hljs-built_in">void</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isDefined</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">x: Maybe&lt;T&gt;</span>): <span class="hljs-title">x</span> <span class="hljs-title">is</span> <span class="hljs-title">T</span> </span>{
    <span class="hljs-keyword">return</span> x !== <span class="hljs-literal">undefined</span> &amp;&amp; x !== <span class="hljs-literal">null</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isUndefined</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">x: Maybe&lt;T&gt;</span>): <span class="hljs-title">x</span> <span class="hljs-title">is</span> <span class="hljs-title">void</span> </span>{
    <span class="hljs-keyword">return</span> x === <span class="hljs-literal">undefined</span> || x === <span class="hljs-literal">null</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getOrElse</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">x: Maybe&lt;T&gt;, defaultValue: T</span>): <span class="hljs-title">T</span> </span>{
    <span class="hljs-keyword">return</span> isDefined(x) ? x : defaultValue;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test1</span>(<span class="hljs-params">x: Maybe&lt;<span class="hljs-built_in">string</span>&gt;</span>) </span>{
    <span class="hljs-keyword">let</span> x1 = getOrElse(x, <span class="hljs-string">&quot;Undefined&quot;</span>);         <span class="hljs-comment">// string</span>
    <span class="hljs-keyword">let</span> x2 = isDefined(x) ? x : <span class="hljs-string">&quot;Undefined&quot;</span>;    <span class="hljs-comment">// string</span>
    <span class="hljs-keyword">let</span> x3 = isUndefined(x) ? <span class="hljs-string">&quot;Undefined&quot;</span> : x;  <span class="hljs-comment">// string</span>
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test2</span>(<span class="hljs-params">x: Maybe&lt;<span class="hljs-built_in">number</span>&gt;</span>) </span>{
    <span class="hljs-keyword">let</span> x1 = getOrElse(x, <span class="hljs-number">-1</span>);         <span class="hljs-comment">// number</span>
    <span class="hljs-keyword">let</span> x2 = isDefined(x) ? x : <span class="hljs-number">-1</span>;    <span class="hljs-comment">// number</span>
    <span class="hljs-keyword">let</span> x3 = isUndefined(x) ? <span class="hljs-number">-1</span> : x;  <span class="hljs-comment">// number</span>
}
</code></pre>
<h2 id="&#x4F7F;&#x7528;---outfile-&#x5408;&#x5E76;-amd-&#x548C;-system-&#x6A21;&#x5757;">&#x4F7F;&#x7528; <code>--outFile</code> &#x5408;&#x5E76; <code>AMD</code> &#x548C; <code>System</code> &#x6A21;&#x5757;</h2>
<p>&#x5728;&#x4F7F;&#x7528; <code>--module amd</code> &#x6216;&#x8005; <code>--module system</code> &#x7684;&#x540C;&#x65F6;&#x5236;&#x5B9A; <code>--outFile</code> &#x5C06;&#x4F1A;&#x628A;&#x6240;&#x6709;&#x53C2;&#x4E0E;&#x7F16;&#x8BD1;&#x7684;&#x6A21;&#x5757;&#x5408;&#x5E76;&#x4E3A;&#x5355;&#x4E2A;&#x5305;&#x62EC;&#x4E86;&#x591A;&#x4E2A;&#x6A21;&#x5757;&#x95ED;&#x5305;&#x7684;&#x8F93;&#x51FA;&#x6587;&#x4EF6;.</p>
<p>&#x6BCF;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x90FD;&#x4F1A;&#x6839;&#x636E;&#x5176;&#x76F8;&#x5BF9;&#x4E8E; <code>rootDir</code> &#x7684;&#x4F4D;&#x7F6E;&#x88AB;&#x8BA1;&#x7B97;&#x51FA;&#x81EA;&#x5DF1;&#x7684;&#x6A21;&#x5757;&#x540D;&#x79F0;.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; src/a.ts</span>
<span class="hljs-keyword">import</span> * as B from <span class="hljs-string">&quot;./lib/b&quot;</span>;
<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createA</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> B.createB();
}
</code></pre>
<pre><code class="lang-ts"><span class="hljs-comment">// &#x6587;&#x4EF6; src/lib/b.ts</span>
<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createB</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> { };
}
</code></pre>
<p>&#x7ED3;&#x679C;&#x4E3A;:</p>
<pre><code class="lang-js">define(<span class="hljs-string">&quot;lib/b&quot;</span>, [<span class="hljs-string">&quot;require&quot;</span>, <span class="hljs-string">&quot;exports&quot;</span>], <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">require, exports</span>) </span>{
<span class="hljs-meta">    &quot;use strict&quot;</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createB</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">return</span> {};
    }
    exports.createB = createB;
});
define(<span class="hljs-string">&quot;a&quot;</span>, [<span class="hljs-string">&quot;require&quot;</span>, <span class="hljs-string">&quot;exports&quot;</span>, <span class="hljs-string">&quot;lib/b&quot;</span>], <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">require, exports, B</span>) </span>{
<span class="hljs-meta">    &quot;use strict&quot;</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createA</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">return</span> B.createB();
    }
    exports.createA = createA;
});
</code></pre>
<h2 id="&#x652F;&#x6301;-systemjs-&#x4F7F;&#x7528;-default-&#x5BFC;&#x5165;">&#x652F;&#x6301; SystemJS &#x4F7F;&#x7528; <code>default</code> &#x5BFC;&#x5165;</h2>
<p>&#x50CF; SystemJS &#x8FD9;&#x6837;&#x7684;&#x6A21;&#x5757;&#x52A0;&#x8F7D;&#x5668;&#x5C06; CommonJS &#x6A21;&#x5757;&#x505A;&#x4E86;&#x5305;&#x88C5;&#x5E76;&#x66B4;&#x9732;&#x4E3A; <code>default</code> ES6 &#x5BFC;&#x5165;&#x9879;. &#x8FD9;&#x4F7F;&#x5F97;&#x5728; SystemJS &#x548C; CommonJS &#x7684;&#x5B9E;&#x73B0;&#x7531;&#x4E8E;&#x4E0D;&#x540C;&#x52A0;&#x8F7D;&#x5668;&#x4E0D;&#x540C;&#x7684;&#x6A21;&#x5757;&#x5BFC;&#x51FA;&#x65B9;&#x5F0F;&#x4E0D;&#x80FD;&#x5171;&#x4EAB;&#x5B9A;&#x4E49;.</p>
<p>&#x8BBE;&#x7F6E;&#x65B0;&#x7684;&#x7F16;&#x8BD1;&#x9009;&#x9879; <code>--allowSyntheticDefaultImports</code> &#x6307;&#x660E;&#x6A21;&#x5757;&#x52A0;&#x8F7D;&#x5668;&#x4F1A;&#x8FDB;&#x884C;&#x5BFC;&#x5165;&#x7684; <code>.ts</code> &#x6216; <code>.d.ts</code> &#x4E2D;&#x672A;&#x6307;&#x5B9A;&#x7684;&#x67D0;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x9ED8;&#x8BA4;&#x5BFC;&#x5165;&#x9879;&#x6784;&#x5EFA;. &#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x7531;&#x6B64;&#x63A8;&#x65AD;&#x5B58;&#x5728;&#x4E00;&#x4E2A; <code>default</code> &#x5BFC;&#x51FA;&#x9879;&#x548C;&#x6574;&#x4E2A;&#x6A21;&#x5757;&#x81EA;&#x5DF1;&#x4E00;&#x81F4;.</p>
<p>&#x6B64;&#x9009;&#x9879;&#x5728; System &#x6A21;&#x5757;&#x9ED8;&#x8BA4;&#x5F00;&#x542F;.</p>
<h2 id="&#x5141;&#x8BB8;&#x5FAA;&#x73AF;&#x4E2D;&#x88AB;&#x5F15;&#x7528;&#x7684;-letconst">&#x5141;&#x8BB8;&#x5FAA;&#x73AF;&#x4E2D;&#x88AB;&#x5F15;&#x7528;&#x7684; <code>let</code>/<code>const</code></h2>
<p>&#x4E4B;&#x524D;&#x8FD9;&#x6837;&#x4F1A;&#x62A5;&#x9519;, &#x73B0;&#x5728;&#x7531; TypeScript 1.8 &#x652F;&#x6301;.
&#x5FAA;&#x73AF;&#x4E2D;&#x88AB;&#x51FD;&#x6570;&#x5F15;&#x7528;&#x7684; <code>let</code>/<code>const</code> &#x58F0;&#x660E;&#x73B0;&#x5728;&#x4F1A;&#x88AB;&#x8F93;&#x51FA;&#x4E3A;&#x4E0E; <code>let</code>/<code>const</code> &#x66F4;&#x65B0;&#x8BED;&#x4E49;&#x76F8;&#x7B26;&#x7684;&#x4EE3;&#x7801;.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> list = [];
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">5</span>; i++) {
    list.push(() =&gt; i);
}

list.forEach(f =&gt; <span class="hljs-built_in">console</span>.log(f()));
</code></pre>
<p>&#x88AB;&#x7F16;&#x8BD1;&#x4E3A;:</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> list = [];
<span class="hljs-keyword">var</span> _loop_1 = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">i</span>) </span>{
    list.push(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-keyword">return</span> i; });
};
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">5</span>; i++) {
    _loop_1(i);
}
list.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">f</span>) </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">console</span>.log(f()); });
</code></pre>
<p>&#x7136;&#x540E;&#x7ED3;&#x679C;&#x662F;:</p>
<pre><code class="lang-cmd"><span class="hljs-number">0</span>
<span class="hljs-number">1</span>
<span class="hljs-number">2</span>
<span class="hljs-number">3</span>
<span class="hljs-number">4</span>
</code></pre>
<h2 id="&#x6539;&#x8FDB;&#x7684;-forin-&#x8BED;&#x53E5;&#x68C0;&#x67E5;">&#x6539;&#x8FDB;&#x7684; <code>for..in</code> &#x8BED;&#x53E5;&#x68C0;&#x67E5;</h2>
<p>&#x8FC7;&#x53BB; <code>for..in</code> &#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x88AB;&#x63A8;&#x65AD;&#x4E3A; <code>any</code>, &#x8FD9;&#x4F7F;&#x5F97;&#x7F16;&#x8BD1;&#x5668;&#x5FFD;&#x7565;&#x4E86; <code>for..in</code> &#x8BED;&#x53E5;&#x5185;&#x7684;&#x4E00;&#x4E9B;&#x4E0D;&#x5408;&#x6CD5;&#x7684;&#x4F7F;&#x7528;.</p>
<p>&#x4ECE; TypeScript 1.8 &#x5F00;&#x59CB;:</p>
<ul>
<li>&#x5728; <code>for..in</code> &#x8BED;&#x53E5;&#x4E2D;&#x7684;&#x53D8;&#x91CF;&#x9690;&#x542B;&#x7C7B;&#x578B;&#x4E3A; <code>string</code>.</li>
<li>&#x5F53;&#x4E00;&#x4E2A;&#x6709;&#x6570;&#x5B57;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x5BF9;&#x5E94;&#x7C7B;&#x578B; <code>T</code> (&#x6BD4;&#x5982;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;) &#x7684;&#x5BF9;&#x8C61;&#x88AB;&#x4E00;&#x4E2A; <code>for..in</code> &#x7D22;&#x5F15;<em>&#x6709;</em>&#x6570;&#x5B57;&#x7D22;&#x5F15;&#x7B7E;&#x540D;&#x5E76;&#x4E14;<em>&#x6CA1;&#x6709;</em>&#x5B57;&#x7B26;&#x4E32;&#x7D22;&#x5F15;&#x7B7E;&#x540D; (&#x6BD4;&#x5982;&#x8FD8;&#x662F;&#x6570;&#x7EC4;) &#x7684;&#x5BF9;&#x8C61;&#x7684;&#x53D8;&#x91CF;&#x7D22;&#x5F15;, &#x4EA7;&#x751F;&#x7684;&#x503C;&#x7684;&#x7C7B;&#x578B;&#x4E3A; <code>T</code>.</li>
</ul>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-keyword">var</span> a: MyObject[];
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> x <span class="hljs-keyword">in</span> a) {   <span class="hljs-comment">// x &#x7684;&#x9690;&#x542B;&#x7C7B;&#x578B;&#x4E3A; string</span>
    <span class="hljs-keyword">var</span> obj = a[x];  <span class="hljs-comment">// obj &#x7684;&#x7C7B;&#x578B;&#x4E3A; MyObject</span>
}
</code></pre>
<h2 id="&#x6A21;&#x5757;&#x73B0;&#x5728;&#x8F93;&#x51FA;&#x65F6;&#x4F1A;&#x52A0;&#x4E0A;-use-strict">&#x6A21;&#x5757;&#x73B0;&#x5728;&#x8F93;&#x51FA;&#x65F6;&#x4F1A;&#x52A0;&#x4E0A; <code>&quot;use strict;&quot;</code></h2>
<p>&#x5BF9;&#x4E8E; ES6 &#x6765;&#x8BF4;&#x6A21;&#x5757;&#x59CB;&#x7EC8;&#x4EE5;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x88AB;&#x89E3;&#x6790;, &#x4F46;&#x8FD9;&#x4E00;&#x70B9;&#x8FC7;&#x53BB;&#x5BF9;&#x4E8E;&#x975E; ES6 &#x76EE;&#x6807;&#x5728;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#x4E2D;&#x5E76;&#x6CA1;&#x6709;&#x9075;&#x5FAA;. &#x4ECE; TypeScript 1.8 &#x5F00;&#x59CB;, &#x8F93;&#x51FA;&#x7684;&#x6A21;&#x5757;&#x603B;&#x4F1A;&#x4E3A;&#x4E25;&#x683C;&#x6A21;&#x5F0F;. &#x7531;&#x4E8E;&#x591A;&#x6570;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x7684;&#x9519;&#x8BEF;&#x4E5F;&#x662F; TS &#x7F16;&#x8BD1;&#x65F6;&#x7684;&#x9519;&#x8BEF;, &#x591A;&#x6570;&#x4EE3;&#x7801;&#x5E76;&#x4E0D;&#x4F1A;&#x6709;&#x53EF;&#x89C1;&#x7684;&#x6539;&#x52A8;, &#x4F46;&#x662F;&#x8FD9;&#x4E5F;&#x610F;&#x5473;&#x7740;&#x6709;&#x4E00;&#x4E9B;&#x4E1C;&#x897F;&#x53EF;&#x80FD;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x6CA1;&#x6709;&#x5F81;&#x5146;&#x5730;&#x5931;&#x8D25;, &#x6BD4;&#x5982;&#x8D4B;&#x503C;&#x7ED9; <code>NaN</code> &#x73B0;&#x5728;&#x4F1A;&#x6709;&#x8FD0;&#x884C;&#x65F6;&#x9519;&#x8BEF;. &#x4F60;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x8FD9;&#x7BC7; <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mod" target="_blank">MDN &#x4E0A;&#x7684;&#x6587;&#x7AE0;</a> &#x67E5;&#x770B;&#x8BE6;&#x7EC6;&#x7684;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0E;&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x7684;&#x533A;&#x522B;&#x5217;&#x8868;.</p>
<h2 id="&#x4F7F;&#x7528;---allowjs-&#x52A0;&#x5165;-js-&#x6587;&#x4EF6;">&#x4F7F;&#x7528; <code>--allowJs</code> &#x52A0;&#x5165; <code>.js</code> &#x6587;&#x4EF6;</h2>
<p>&#x7ECF;&#x5E38;&#x5728;&#x9879;&#x76EE;&#x4E2D;&#x4F1A;&#x6709;&#x5916;&#x90E8;&#x7684;&#x975E; TypeScript &#x7F16;&#x5199;&#x7684;&#x6E90;&#x6587;&#x4EF6;.
&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x662F;&#x5C06; JS &#x4EE3;&#x7801;&#x8F6C;&#x6362;&#x4E3A; TS &#x4EE3;&#x7801;, &#x4F46;&#x8FD9;&#x65F6;&#x53C8;&#x5E0C;&#x671B;&#x5C06;&#x6240;&#x6709; JS &#x4EE3;&#x7801;&#x548C;&#x65B0;&#x7684; TS &#x4EE3;&#x7801;&#x7684;&#x8F93;&#x51FA;&#x4E00;&#x8D77;&#x6253;&#x5305;&#x4E3A;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;.</p>
<p><code>.js</code> &#x6587;&#x4EF6;&#x73B0;&#x5728;&#x5141;&#x8BB8;&#x4F5C;&#x4E3A; <code>tsc</code> &#x7684;&#x8F93;&#x5165;&#x6587;&#x4EF6;. TypeScript &#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x68C0;&#x67E5; <code>.js</code> &#x8F93;&#x5165;&#x6587;&#x4EF6;&#x7684;&#x8BED;&#x6CD5;&#x9519;&#x8BEF;, &#x5E76;&#x6839;&#x636E; <code>--target</code> &#x548C; <code>--module</code> &#x9009;&#x9879;&#x8F93;&#x51FA;&#x5BF9;&#x5E94;&#x7684;&#x4EE3;&#x7801;.
&#x8F93;&#x51FA;&#x4E5F;&#x4F1A;&#x548C;&#x5176;&#x4ED6; <code>.ts</code> &#x6587;&#x4EF6;&#x4E00;&#x8D77;. <code>.js</code> &#x6587;&#x4EF6;&#x7684; source maps &#x4E5F;&#x4F1A;&#x50CF; <code>.ts</code> &#x6587;&#x4EF6;&#x4E00;&#x6837;&#x88AB;&#x751F;&#x6210;.</p>
<h2 id="&#x4F7F;&#x7528;---reactnamespace-&#x81EA;&#x5B9A;&#x4E49;-jsx-&#x5DE5;&#x5382;">&#x4F7F;&#x7528; <code>--reactNamespace</code> &#x81EA;&#x5B9A;&#x4E49; JSX &#x5DE5;&#x5382;</h2>
<p>&#x5728;&#x4F7F;&#x7528; <code>--jsx react</code> &#x7684;&#x540C;&#x65F6;&#x4F7F;&#x7528; <code>--reactNamespace &lt;JSX &#x5DE5;&#x5382;&#x540D;&#x79F0;&gt;</code> &#x53EF;&#x4EE5;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x4E0D;&#x540C;&#x7684; JSX &#x5DE5;&#x5382;&#x4EE3;&#x66FF;&#x9ED8;&#x8BA4;&#x7684; <code>React</code>.</p>
<p>&#x65B0;&#x7684;&#x5DE5;&#x5382;&#x540D;&#x79F0;&#x4F1A;&#x88AB;&#x7528;&#x6765;&#x8C03;&#x7528; <code>createElement</code> &#x548C; <code>__spread</code> &#x65B9;&#x6CD5;.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts">import {jsxFactory} from &quot;jsxFactory&quot;;

var div = &lt;div&gt;Hello JSX!&lt;/div&gt;
</code></pre>
<p>&#x7F16;&#x8BD1;&#x53C2;&#x6570;:</p>
<pre><code class="lang-shell">tsc --jsx react --reactNamespace jsxFactory --m commonJS
</code></pre>
<p>&#x7ED3;&#x679C;:</p>
<pre><code class="lang-js"><span class="hljs-meta">&quot;use strict&quot;</span>;
<span class="hljs-keyword">var</span> jsxFactory_1 = <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;jsxFactory&quot;</span>);
<span class="hljs-keyword">var</span> div = jsxFactory_1.jsxFactory.createElement(<span class="hljs-string">&quot;div&quot;</span>, <span class="hljs-literal">null</span>, <span class="hljs-string">&quot;Hello JSX!&quot;</span>);
</code></pre>
<h2 id="&#x57FA;&#x4E8E;-this-&#x7684;&#x7C7B;&#x578B;&#x6536;&#x7A84;">&#x57FA;&#x4E8E; <code>this</code> &#x7684;&#x7C7B;&#x578B;&#x6536;&#x7A84;</h2>
<p>TypeScript 1.8 &#x4E3A;&#x7C7B;&#x548C;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x6269;&#x5C55;&#x4E86;<a href="#&#x7528;&#x6237;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x578B;&#x6536;&#x7A84;&#x51FD;&#x6570;">&#x7528;&#x6237;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x578B;&#x6536;&#x7A84;&#x51FD;&#x6570;</a>.</p>
<p><code>this is T</code> &#x73B0;&#x5728;&#x662F;&#x7C7B;&#x6216;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x7684;&#x5408;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x6807;&#x6CE8;.
&#x5F53;&#x5728;&#x7C7B;&#x578B;&#x6536;&#x7A84;&#x7684;&#x4F4D;&#x7F6E;&#x4F7F;&#x7528;&#x65F6; (&#x6BD4;&#x5982; <code>if</code> &#x8BED;&#x53E5;), &#x51FD;&#x6570;&#x8C03;&#x7528;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x76EE;&#x6807;&#x5BF9;&#x8C61;&#x7684;&#x7C7B;&#x578B;&#x4F1A;&#x88AB;&#x6536;&#x7A84;&#x4E3A; <code>T</code>.</p>
<h3 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h3>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> FileSystemObject {
    isFile(): <span class="hljs-keyword">this</span> is File { <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> File; }
    isDirectory(): <span class="hljs-keyword">this</span> is Directory { <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> Directory;}
    isNetworked(): <span class="hljs-keyword">this</span> is (Networked &amp; <span class="hljs-keyword">this</span>) { <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.networked; }
    <span class="hljs-keyword">constructor</span>(public path: string, private networked: boolean) {}
}

<span class="hljs-keyword">class</span> File extends FileSystemObject {
    <span class="hljs-keyword">constructor</span>(path: string, public content: string) { <span class="hljs-keyword">super</span>(path, <span class="hljs-literal">false</span>); }
}
<span class="hljs-keyword">class</span> Directory extends FileSystemObject {
    children: FileSystemObject[];
}
<span class="hljs-keyword">interface</span> Networked {
    host: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">let</span> fso: FileSystemObject = <span class="hljs-keyword">new</span> File(<span class="hljs-string">&quot;foo/bar.txt&quot;</span>, <span class="hljs-string">&quot;foo&quot;</span>);
<span class="hljs-keyword">if</span> (fso.isFile()) {
    fso.content; <span class="hljs-comment">// fso &#x662F; File</span>
}
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (fso.isDirectory()) {
    fso.children; <span class="hljs-comment">// fso &#x662F; Directory</span>
}
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (fso.isNetworked()) {
    fso.host; <span class="hljs-comment">// fso &#x662F; networked</span>
}
</code></pre>
<h2 id="&#x5B98;&#x65B9;&#x7684;-typescript-nuget-&#x5305;">&#x5B98;&#x65B9;&#x7684; TypeScript NuGet &#x5305;</h2>
<p>&#x4ECE; TypeScript 1.8 &#x5F00;&#x59CB;, &#x5C06;&#x4E3A; TypeScript &#x7F16;&#x8BD1;&#x5668; (<code>tsc.exe</code>) &#x548C; MSBuild &#x6574;&#x5408; (<code>Microsoft.TypeScript.targets</code> &#x548C; <code>Microsoft.TypeScript.Tasks.dll</code>) &#x63D0;&#x4F9B;&#x5B98;&#x65B9;&#x7684; NuGet &#x5305;.</p>
<p>&#x7A33;&#x5B9A;&#x7248;&#x672C;&#x53EF;&#x4EE5;&#x5728;&#x8FD9;&#x91CC;&#x4E0B;&#x8F7D;:</p>
<ul>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.Compiler/" target="_blank">Microsoft.TypeScript.Compiler</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild/" target="_blank">Microsoft.TypeScript.MSBuild</a></li>
</ul>
<p>&#x4E0E;&#x6B64;&#x540C;&#x65F6;, &#x548C;<a href="https://blogs.msdn.com/b/typescript/archive/2015/07/27/introducing-typescript-nightlies.aspx" target="_blank">&#x6BCF;&#x65E5;npm&#x5305;</a>&#x5BF9;&#x5E94;&#x7684;&#x6BCF;&#x65E5; NuGet &#x5305;&#x53EF;&#x4EE5;&#x5728;<a href="https://myget.org" target="_blank">https://myget.org</a>&#x4E0B;&#x8F7D;:</p>
<ul>
<li><a href="https://www.myget.org/gallery/typescript-preview" target="_blank">TypeScript-Preview</a></li>
</ul>
<h2 id="tsc-&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x66F4;&#x7F8E;&#x89C2;"><code>tsc</code> &#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x66F4;&#x7F8E;&#x89C2;</h2>
<p>&#x6211;&#x4EEC;&#x7406;&#x89E3;&#x5927;&#x91CF;&#x5355;&#x8272;&#x7684;&#x8F93;&#x51FA;&#x5E76;&#x4E0D;&#x76F4;&#x89C2;. &#x989C;&#x8272;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x8BC6;&#x522B;&#x4FE1;&#x606F;&#x7684;&#x59CB;&#x672B;, &#x8FD9;&#x4E9B;&#x89C6;&#x89C9;&#x4E0A;&#x7684;&#x7EBF;&#x7D22;&#x5728;&#x5904;&#x7406;&#x590D;&#x6742;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x65F6;&#x975E;&#x5E38;&#x91CD;&#x8981;.</p>
<p>&#x901A;&#x8FC7;&#x4F20;&#x9012; <code>--pretty</code> &#x547D;&#x4EE4;&#x884C;&#x9009;&#x9879;, TypeScript &#x4F1A;&#x7ED9;&#x51FA;&#x66F4;&#x4E30;&#x5BCC;&#x7684;&#x8F93;&#x51FA;, &#x5305;&#x542B;&#x9519;&#x8BEF;&#x53D1;&#x751F;&#x7684;&#x4E0A;&#x4E0B;&#x6587;.</p>
<p><img src="https://raw.githubusercontent.com/wiki/Microsoft/TypeScript/images/new-in-typescript/pretty01.png" alt="&#x5C55;&#x793A;&#x5728; ConEmu &#x4E2D;&#x7F8E;&#x5316;&#x4E4B;&#x540E;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;"></p>
<h2 id="&#x9AD8;&#x4EAE;-vs-2015-&#x4E2D;&#x7684;-jsx-&#x4EE3;&#x7801;">&#x9AD8;&#x4EAE; VS 2015 &#x4E2D;&#x7684; JSX &#x4EE3;&#x7801;</h2>
<p>&#x5728; TypeScript 1.8 &#x4E2D;, JSX &#x6807;&#x7B7E;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x5728; Visual Studio 2015 &#x4E2D;&#x88AB;&#x5206;&#x522B;&#x548C;&#x9AD8;&#x4EAE;.</p>
<p><img src="https://cloud.githubusercontent.com/assets/8052307/12271404/b875c502-b90f-11e5-93d8-c6740be354d1.png" alt="jsx"></p>
<p>&#x901A;&#x8FC7; <code>&#x5DE5;&#x5177;</code>-&gt;<code>&#x9009;&#x9879;</code>-&gt;<code>&#x73AF;&#x5883;</code>-&gt;<code>&#x5B57;&#x4F53;&#x4E0E;&#x989C;&#x8272;</code> &#x9875;&#x9762;&#x5728; <code>VB XML</code> &#x989C;&#x8272;&#x548C;&#x5B57;&#x4F53;&#x8BBE;&#x7F6E;&#x4E2D;&#x8FD8;&#x53EF;&#x4EE5;&#x8FDB;&#x4E00;&#x6B65;&#x6539;&#x53D8;&#x5B57;&#x4F53;&#x548C;&#x989C;&#x8272;&#x6765;&#x81EA;&#x5B9A;&#x4E49;.</p>
<h2 id="-project--p-&#x9009;&#x9879;&#x73B0;&#x5728;&#x63A5;&#x53D7;&#x4EFB;&#x610F;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;"><code>--project</code> (<code>-p</code>) &#x9009;&#x9879;&#x73B0;&#x5728;&#x63A5;&#x53D7;&#x4EFB;&#x610F;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</h2>
<p><code>--project</code> &#x547D;&#x4EE4;&#x884C;&#x9009;&#x9879;&#x8FC7;&#x53BB;&#x53EA;&#x63A5;&#x53D7;&#x5305;&#x542B;&#x4E86; <code>tsconfig.json</code> &#x6587;&#x4EF6;&#x7684;&#x6587;&#x4EF6;&#x5939;.
&#x8003;&#x8651;&#x5230;&#x4E0D;&#x540C;&#x7684;&#x6784;&#x5EFA;&#x573A;&#x666F;, &#x5E94;&#x8BE5;&#x5141;&#x8BB8; <code>--project</code> &#x6307;&#x5411;&#x4EFB;&#x4F55;&#x517C;&#x5BB9;&#x7684; JSON &#x6587;&#x4EF6;.
&#x6BD4;&#x5982;&#x8BF4;, &#x4E00;&#x4E2A;&#x7528;&#x6237;&#x53EF;&#x80FD;&#x4F1A;&#x5E0C;&#x671B;&#x4E3A; Node 5 &#x7F16;&#x8BD1; CommonJS &#x7684; ES 2015, &#x4E3A;&#x6D4F;&#x89C8;&#x5668;&#x7F16;&#x8BD1; AMD &#x7684; ES5.
&#x73B0;&#x5728;&#x5C11;&#x4E86;&#x8FD9;&#x9879;&#x9650;&#x5236;, &#x7528;&#x6237;&#x53EF;&#x4EE5;&#x66F4;&#x5BB9;&#x6613;&#x5730;&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>tsc</code> &#x7BA1;&#x7406;&#x4E0D;&#x540C;&#x7684;&#x6784;&#x5EFA;&#x76EE;&#x6807;, &#x65E0;&#x9700;&#x518D;&#x901A;&#x8FC7;&#x4E00;&#x4E9B;&#x5947;&#x602A;&#x7684;&#x65B9;&#x5F0F;, &#x6BD4;&#x5982;&#x5C06;&#x591A;&#x4E2A; <code>tsconfig.json</code> &#x6587;&#x4EF6;&#x653E;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x76EE;&#x5F55;&#x4E2D;.</p>
<p>&#x5982;&#x679C;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x8DEF;&#x5F84;, &#x884C;&#x4E3A;&#x4FDD;&#x6301;&#x4E0D;&#x53D8; - &#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x5C1D;&#x8BD5;&#x5728;&#x8BE5;&#x76EE;&#x5F55;&#x4E0B;&#x5BFB;&#x627E;&#x540D;&#x4E3A; <code>tsconfig.json</code> &#x7684;&#x6587;&#x4EF6;.</p>
<h2 id="&#x5141;&#x8BB8;-tsconfigjson-&#x4E2D;&#x7684;&#x6CE8;&#x91CA;">&#x5141;&#x8BB8; tsconfig.json &#x4E2D;&#x7684;&#x6CE8;&#x91CA;</h2>
<p>&#x4E3A;&#x914D;&#x7F6E;&#x6DFB;&#x52A0;&#x6587;&#x6863;&#x662F;&#x5F88;&#x68D2;&#x7684;! <code>tsconfig.json</code> &#x73B0;&#x5728;&#x652F;&#x6301;&#x5355;&#x884C;&#x548C;&#x591A;&#x884C;&#x6CE8;&#x91CA;.</p>
<pre><code class="lang-json">{
    <span class="hljs-string">&quot;compilerOptions&quot;</span>: {
        <span class="hljs-string">&quot;target&quot;</span>: <span class="hljs-string">&quot;ES2015&quot;</span>, <span class="hljs-comment">// &#x8DD1;&#x5728; node v5 &#x4E0A;, &#x5440;!</span>
        <span class="hljs-string">&quot;sourceMap&quot;</span>: <span class="hljs-literal">true</span>   <span class="hljs-comment">// &#x8BA9;&#x8C03;&#x8BD5;&#x8F7B;&#x677E;&#x4E00;&#x4E9B;</span>
    },
    <span class="hljs-comment">/*
     * &#x6392;&#x9664;&#x7684;&#x6587;&#x4EF6;
     */</span>
    <span class="hljs-string">&quot;exclude&quot;</span>: [
        <span class="hljs-string">&quot;file.d.ts&quot;</span>
    ]
}
</code></pre>
<h2 id="&#x652F;&#x6301;&#x8F93;&#x51FA;&#x5230;-ipc-&#x9A71;&#x52A8;&#x7684;&#x6587;&#x4EF6;">&#x652F;&#x6301;&#x8F93;&#x51FA;&#x5230; IPC &#x9A71;&#x52A8;&#x7684;&#x6587;&#x4EF6;</h2>
<p>TypeScript 1.8 &#x5141;&#x8BB8;&#x7528;&#x6237;&#x5C06; <code>--outFile</code> &#x53C2;&#x6570;&#x548C;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x5BF9;&#x8C61;&#x4E00;&#x8D77;&#x4F7F;&#x7528;, &#x6BD4;&#x5982;&#x547D;&#x540D;&#x7684;&#x7BA1;&#x9053; (pipe), &#x8BBE;&#x5907; (devices) &#x7B49;.</p>
<p>&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;, &#x5728;&#x5F88;&#x591A;&#x4E0E; Unix &#x76F8;&#x4F3C;&#x7684;&#x7CFB;&#x7EDF;&#x4E0A;, &#x6807;&#x51C6;&#x8F93;&#x51FA;&#x6D41;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6587;&#x4EF6; <code>/dev/stdout</code> &#x8BBF;&#x95EE;.</p>
<pre><code class="lang-sh">tsc foo.ts --outFile /dev/stdout
</code></pre>
<p>&#x8FD9;&#x4E00;&#x7279;&#x6027;&#x4E5F;&#x5141;&#x8BB8;&#x8F93;&#x51FA;&#x7ED9;&#x5176;&#x4ED6;&#x547D;&#x4EE4;.</p>
<p>&#x6BD4;&#x5982;&#x8BF4;, &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8F93;&#x51FA;&#x751F;&#x6210;&#x7684; JavaScript &#x7ED9;&#x4E00;&#x4E2A;&#x50CF; <a href="https://www.npmjs.com/package/pretty-js" target="_blank">pretty-js</a> &#x8FD9;&#x6837;&#x7684;&#x683C;&#x5F0F;&#x7F8E;&#x5316;&#x5DE5;&#x5177;:</p>
<pre><code class="lang-sh">tsc foo.ts --outFile /dev/stdout | pretty-js
</code></pre>
<h2 id="&#x6539;&#x8FDB;&#x4E86;-visual-studio-2015-&#x4E2D;&#x5BF9;-tsconfigjson-&#x7684;&#x652F;&#x6301;">&#x6539;&#x8FDB;&#x4E86; Visual Studio 2015 &#x4E2D;&#x5BF9; <code>tsconfig.json</code> &#x7684;&#x652F;&#x6301;</h2>
<p>TypeScript 1.8 &#x5141;&#x8BB8;&#x5728;&#x4EFB;&#x4F55;&#x79CD;&#x7C7B;&#x7684;&#x9879;&#x76EE;&#x4E2D;&#x4F7F;&#x7528; <code>tsconfig.json</code> &#x6587;&#x4EF6;.
&#x5305;&#x62EC; ASP.NET v4 &#x9879;&#x76EE;, <em>&#x63A7;&#x5236;&#x53F0;&#x5E94;&#x7528;</em>, &#x4EE5;&#x53CA; <em>&#x7528; TypeScript &#x5F00;&#x53D1;&#x7684; HTML &#x5E94;&#x7528;</em>.
&#x4E0E;&#x6B64;&#x540C;&#x65F6;, &#x4F60;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x4E0D;&#x6B62;&#x4E00;&#x4E2A; <code>tsconfig.json</code> &#x6587;&#x4EF6;, &#x5176;&#x4E2D;&#x6BCF;&#x4E00;&#x4E2A;&#x90FD;&#x4F1A;&#x4F5C;&#x4E3A;&#x9879;&#x76EE;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x88AB;&#x6784;&#x5EFA;.
&#x8FD9;&#x4F7F;&#x5F97;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x4E0D;&#x540C;&#x9879;&#x76EE;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x4E3A;&#x5E94;&#x7528;&#x7684;&#x4E0D;&#x540C;&#x90E8;&#x5206;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x914D;&#x7F6E;.</p>
<p><img src="https://raw.githubusercontent.com/wiki/Microsoft/TypeScript/images/new-in-typescript/tsconfig-in-vs.png" alt="&#x5C55;&#x793A; Visual Studio &#x4E2D;&#x7684; tsconfig.json"></p>
<p>&#x5F53;&#x9879;&#x76EE;&#x4E2D;&#x6DFB;&#x52A0;&#x4E86; <code>tsconfig.json</code> &#x6587;&#x4EF6;&#x65F6;, &#x6211;&#x4EEC;&#x8FD8;&#x7981;&#x7528;&#x4E86;&#x9879;&#x76EE;&#x5C5E;&#x6027;&#x9875;&#x9762;.
&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6240;&#x6709;&#x914D;&#x7F6E;&#x7684;&#x6539;&#x53D8;&#x5FC5;&#x987B;&#x5728; <code>tsconfig.json</code> &#x6587;&#x4EF6;&#x4E2D;&#x8FDB;&#x884C;.</p>
<h3 id="&#x4E00;&#x4E9B;&#x9650;&#x5236;">&#x4E00;&#x4E9B;&#x9650;&#x5236;</h3>
<ul>
<li>&#x5982;&#x679C;&#x4F60;&#x6DFB;&#x52A0;&#x4E86;&#x4E00;&#x4E2A; <code>tsconfig.json</code> &#x6587;&#x4EF6;, &#x4E0D;&#x5728;&#x5176;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x7684; TypeScript &#x6587;&#x4EF6;&#x4E0D;&#x4F1A;&#x88AB;&#x7F16;&#x8BD1;.</li>
<li>Apache Cordova &#x5E94;&#x7528;&#x4F9D;&#x7136;&#x6709;&#x5355;&#x4E2A; <code>tsconfig.json</code> &#x6587;&#x4EF6;&#x7684;&#x9650;&#x5236;, &#x800C;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5FC5;&#x987B;&#x5728;&#x6839;&#x76EE;&#x5F55;&#x6216;&#x8005; <code>scripts</code> &#x6587;&#x4EF6;&#x5939;.</li>
<li>&#x591A;&#x6570;&#x9879;&#x76EE;&#x7C7B;&#x578B;&#x4E2D;&#x90FD;&#x6CA1;&#x6709; <code>tsconfig.json</code> &#x7684;&#x6A21;&#x677F;.</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="TypeScript 2.0.html" class="navigation navigation-prev " aria-label="Previous page: TypeScript 2.0">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="TypeScript 1.7.html" class="navigation navigation-next " aria-label="Next page: TypeScript 1.7">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"TypeScript 1.8","level":"1.7.13","depth":2,"next":{"title":"TypeScript 1.7","level":"1.7.14","depth":2,"path":"doc/release-notes/TypeScript 1.7.md","ref":"./doc/release-notes/TypeScript 1.7.md","articles":[]},"previous":{"title":"TypeScript 2.0","level":"1.7.12","depth":2,"path":"doc/release-notes/TypeScript 2.0.md","ref":"./doc/release-notes/TypeScript 2.0.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/release-notes/TypeScript 1.8.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

